<template>
	<view>
		<view class="ffffff mainpadding_top flexbetween">
			<view class="titletext hei_text bold">原密碼</view>
			<input type="text"placeholder="請輸入" v-model="oldpass" style="text-align: right;" class="hei_text main_size bold">
		</view>
		<view class="ffffff mainpadding_top flexbetween">
			<view class="titletext hei_text bold">新密碼</view>
			<input type="text"placeholder="請輸入" v-model="pass" style="text-align: right;" class="hei_text main_size bold">
		</view>
		<view class="ffffff mainpadding_top flexbetween">
			<view class="titletext hei_text bold">確認新密碼</view>
			<input type="text"placeholder="請輸入"  v-model="newpass" style="text-align: right;" class="hei_text main_size bold">
		</view>
		<view class="posibottom mainpadding" style="bottom: 0;">
			<view class="submitbtn" @click="add()">保存</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldpass:'',
				pass:'',
				newpass:'',
			}
		},
		methods: {
			async add(){
				if(this.oldpass==""){
						this.http.toast('請輸入原密碼')
					return
				}
				if(this.pass==""){
						this.http.toast('請輸入新密碼')
					return
				}
				if(this.newpass==""){
						this.http.toast('請輸入確認密碼')
					return
				}
				if(this.pass==this.oldpass){
						this.http.toast('新密碼和原密碼一致')
					return
				}
				if(this.pass!=this.newpass){
						this.http.toast('兩次輸入不一致')
					
					return
				}
				let res = await this.http.request('/api/shop/editpass', 'POST', {
					oldpassword:this.oldpass,
					newpass:this.newpass
				})
				if (res.code == 1) {
					this.http.toast(res.msg)
					this.oldpass=""
					this.pass=""
					this.newpass=""
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			}
		}
	}
</script>

<style>

</style>
